package com.trembear.carclient.controller;

import com.trembear.carclient.api.LoginResultType;
import com.trembear.carclient.api.UcarincadminClientService;
import com.ucarinc.base.ucarincadmin.login.yccadmin.V1.YccAdminLoginRe;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Junwei.Xiong
 * @description:
 * @create 2018-07-10 10:04
 */
@RestController
@RequestMapping("/car")
public class CarController {
    @Autowired
    UcarincadminClientService ucarincadminClientService;
    @GetMapping("/volvo")
    public String getCar() {
        YccAdminLoginRe re = ucarincadminClientService.yccAdminLogin("junwei.xiong", "123");
        if (re == null) {
            return "未获取员工信息，请重试！";
        } else if (re.getStatus() == LoginResultType.UN_VERIFY) {
            return "邮箱前缀或密码错误";
        } else if (re.getStatus() == LoginResultType.FREEZE) {
            return "统一平台对应账号已冻结，请联系系统管理员";
        } else if (re.getStatus() == LoginResultType.ERROR_INSERT) {
            return "统一平台初始化插入emp记录失败";
        } else if (re.getStatus() == LoginResultType.ERROR_LDAP) {
            return "LDAP校验异常";
        } else if (re.getStatus() == LoginResultType.UNBIND_SAP) {
            return "邮箱不是sap绑定邮箱";
        } else if (re.getStatus() == LoginResultType.OK) {
            return "success";
        }else{
            return "unknow Message";
        }
    }
}
